package ec.genetic.impl;

import java.util.Random;

public class ParentChromosomes {
	
	public Chromosome firstParent;
	public Chromosome secondParent;
	public Chromosome child;
	
	public ParentChromosomes(Chromosome firstParent, Chromosome secondParent) {
		this.firstParent = firstParent;
		this.secondParent = secondParent;
		this.child = new Chromosome();
	}

	/**
	 * One-point crossover for parents (chromosomes) 
	 * @param firstParent
	 * @param secondParent
	 * @return parents' child
	 */
	
	void onePointCrossover(int numberForChild){
		

		int childLen = 64;
		Random rand = new Random();
		int crossoverPoint1 = rand.nextInt(6) + 1;
		int crossoverPoint2 = 12 + (int)(Math.random() * ((64 - 12) + 1));
		this.child.chromosomeNumber = numberForChild;
		this.child.data = firstParent.data.substring(0, crossoverPoint1) + secondParent.data.substring(crossoverPoint1, crossoverPoint2)
				+ firstParent.data.substring(0, childLen);
		
	}

}
